package com.qzimp.fujiancuo.mapper;

import com.qzimp.fujiancuo.entity.Visitor;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VisitorMapper {

    @Select("SELECT * FROM tb_visitor WHERE visitor_id = #{visitorId}")
    Visitor getVisitorById(Long visitorId);

    @Select("SELECT * FROM tb_visitor")
    List<Visitor> getAllVisitors();

    @Insert("INSERT INTO tb_visitor(name, phone, email) VALUES(#{name}, #{phone}, #{email})")
    void addVisitor(Visitor visitor);

    @Update("UPDATE tb_visitor SET name = #{name}, phone = #{phone}, email = #{email} WHERE visitor_id = #{visitorId}")
    void updateVisitor(Visitor visitor);

    @Delete("DELETE FROM tb_visitor WHERE visitor_id = #{visitorId}")
    void deleteVisitor(Long visitorId);
}